import {combineReducers} from 'redux';
import * as constants from './actionTypes';

export const data = (state={
    data:{},
    isFetching: false
}, action) =>{
    switch(action.type){
        case constants.FETCH_DATA_REQUEST:
            return {
                ...state,
                isFetching: true
            }
        case constants.FETCH_DATA_SUCCESS:
            return {
                ...state,
                data: action.data,
                isFetching: false
            }
        case constants.FETCH_DATA_FAILURE:
            return {
                ...state,
                isFetching: false
            }
        default:
            return state;
    }
}


export default combineReducers({
    data
})
